Respect RFC 6901, use ESM output, add new mergeKeys dereference option.#398
Merged
Respect RFC 6901, use ESM output, add new mergeKeys dereference option.#398
Conversation
BREAKING CHANGE: Change default merge keys option and add merge keys strategy, bump dependencies
There was a problem hiding this comment.
Pull Request Overview
This pull request implements RFC 6901-compliant JSON pointer handling, migrates to ESM output, and adds a new mergeKeys dereference option. The changes address URL encoding issues that caused characters like $ in JSON pointers to be unnecessarily encoded, breaking references to JSON Schema $defs.
Key changes:
- Remove unnecessary
encodeURIComponent/decodeURIComponentcalls in JSON pointer parsing and construction, keeping only RFC 6901-required encoding (~→~0,/→~1) - Update
tsconfig.jsonto output ESM modules (NodeNext,node16module resolution) - Add
mergeKeysoption to control key merging during dereferencing (defaults totrue)
Reviewed Changes
Copilot reviewed 28 out of 31 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
lib/util/url.ts |
Removes URL decoding in safePointerToPath and adds hash decoding in resolve |
lib/pointer.ts |
Removes URL encoding in Pointer.join and decoding in Pointer.parse per RFC 6901 |
lib/ref.ts |
Adds deepMerge logic and mergeKeys option support to control key collision handling |
lib/options.ts |
Defines new mergeKeys option with default true |
test/specs/bundle-defs-encoding/ |
New test suite verifying $defs references are not URL-encoded |
tsconfig.json |
Updates to ESM output configuration |
package.json |
Updates module type to "module" and dependency versions |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Pull Request Test Coverage Report for Build 19275102544Details
💛 - Coveralls |
|
🎉 This PR is included in version 15.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This changes the URL parsing behavior to actually respect RFC 6901. Previously we were URL encoding too often. This will be considered a breaking change, as it will change how previously parsed documents are bundled and dereferenced.
This also adds a new mergeKey option.
Additionally, the new output will be ESM.
Should fix #383, #356, and makes progress on #370
BREAKING CHANGE: Change URL encoding to use strict RFC 6901, add new mergeKeys dereference option